package com.example.goandroiddemo.view;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.chouren.goandroid.ui.view.Bar;
import com.chouren.goandroid.ui.view.Diagram;
import com.chouren.goandroid.ui.view.TextArc;
import com.chouren.goandroid.ui.view.model.BarParam;
import com.chouren.goandroid.ui.view.model.DiagramParam;
import com.example.goandroiddemo.R;

public class CustomViewsTestActivity extends Activity {
	private LinearLayout mTextCircle;
	private RelativeLayout mBar;
	private RelativeLayout mDiagram;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_custom_views_test);
		
		mTextCircle = (LinearLayout)findViewById(R.id.textCircle);
		mBar = (RelativeLayout)findViewById(R.id.bar);
		mDiagram = (RelativeLayout)findViewById(R.id.diagram);
		
		mTextCircle.addView(new TextArc(this, 100));
		mBar.addView(new Bar(this, getBarData(), 100));
		mDiagram.addView(new Diagram(this, getDiagramData(), 300));
	}
	
	private List<BarParam> getBarData() {
		List<BarParam> data = new ArrayList<BarParam>();
		for(int i = 0; i < 10; i++) {
			BarParam barParam = new BarParam("key" + i, i * 8);
			data.add(barParam);
		}
		return data;
	}
	
	private List<DiagramParam> getDiagramData() {
		List<DiagramParam> data = new ArrayList<DiagramParam>();
		for(int i = 0; i < 30; i++) {
			DiagramParam dp = new DiagramParam();
			if(i % 2 == 0) {
				dp.setKey("key" + i);
				dp.setValue(i * 8);
			}else { 
				dp.setKey("key" + i);
				dp.setValue(new Random().nextInt(10) * 8);
			}
			data.add(dp);
		}
		return data;
	}
}
